﻿using System;
using System.ComponentModel.DataAnnotations;
using System.Runtime.Serialization;
using Microsoft.Practices.EnterpriseLibrary.Validation.Validators;

namespace Metro.Kashikoi.ServiceContract.Storage
{
    /// <summary>
    /// This class defines the daily trigger.
    /// </summary>
    [DataContract(IsReference = true)]
    [Table("DailyTriggers")]
    public class DailyTrigger : AutoTrigger
    {
        /// <summary>
        /// Gets or sets the time of a day.
        /// </summary>
        /// <value>
        /// The time.
        /// </value>
        [DataMember]
        [Required]
        [DateTimeRangeValidator("1753-01-01T00:00:00", "9999-12-31T00:00:00")]
        public DateTime Time { get; set; }

        /// <summary>
        /// Copies the specified to the destination.
        /// </summary>
        /// <param name="destination">The destination.</param>
        public void CopyTo(DailyTrigger destination)
        {
            base.CopyTo(destination);
            destination.Time = this.Time;
        }

        /// <summary>
        /// Clones this instance.
        /// </summary>
        /// <returns>
        /// Newly cloned instance.
        /// </returns>
        public override Trigger Clone()
        {
            var trigger = new DailyTrigger ();
            this.CopyTo(trigger);
            return trigger;
        }
    }
}
